<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>留言板——所有留言</title>

    <!-- 1.Bootstrap css样式  -->
    <link href="../dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="../dist/css/bootstrap-theme.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="../navbar.css" rel="stylesheet">
    <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
    <link href="../css/f.css" rel="stylesheet" type="text/css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  <script type="text/javascript"></script>
 </head>
  
 <body>
                     
<div class="container">
	<nav class="navbar navbar-default ">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#">留言板</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            	<li class="alert-info"><a href="allComments.php">所有留言</a></li>
 				<li class="alert-warning"><a href="myComments.php">我的留言</a></li>            
                <li class="alert-success"><a href="myPinglun.php">我的评论</a></li> 
          </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right  ">
            <li class="myFont2">欢迎你：</li>
            <li class="myFont2"><?php 
				 session_start(); 
				 echo $_SESSION['user_name']; 
				 ?>
            </li>
          <li><a href="../index.php" class="myFont1">[注销]</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>
</div>

<div class="container">    	
        <a href="leaveComments.php"><input type="submit" class="btn btn-info" value="我要留言" ></a>
 </div>
  
 <div class="container">
      <div class="jumbotron">
      	<?php 
			$conn=mysql_connect("localhost","root","root") or die("数据库连接失败！");
			mysql_select_db("guestbook") or die("数据库打开失败！");
			mysql_query("set names utf8");
			$result=mysql_query("select * from stateinfo where parentId='0'");
			$count=mysql_num_rows($result);
			for($i=0;$i<$count;$i++){	
				 $data=mysql_fetch_array($result); 
				 if($i%3==0){
					 $bgc='bg-info';
				 }
				 else if($i%3==1){
					 $bgc='bg-warning';
				 }else{
					 $bgc='bg-danger';
				 }
		?>
      	 <div class="row  <?php echo $bgc?>">
          	 <h2><span class="glyphicon glyphicon-envelope"></span>
             		<a href="displayComments.php?currentTheme=<?php echo $data['theme']; ?>">
					 <?php
					 echo $data['theme'];
					?></a>
                    <?php if($_SESSION['user_name']=="admin"){
						?>
                    <a href="../control/deleteComments.php?theme=<?php echo $data['theme']; ?>" class="myFont4">[删除]</a>
                    <?php }?>
              </h2>
             <p><?php 
			 $str=$data['text'];
			 if(strlen($data['text'])>80){
				 $str=mb_substr($data['text'],0,40,'utf-8');
				 $str=$str."....";
			 }
				echo $str;
			 ?></p>
             <div class="text-right">
             		<p class="small" >评论【<?php 
					$name=$data['username'];
					$pl=mysql_query("select *from stateinfo where parentId='$name'");
					echo mysql_num_rows($pl);
					?>】<?php echo $data['username']."|"  .$data['stadate']?></p> 
             </div>
      </div>
      <?php
			}
			mysql_close($conn);
		?>
  </div> 
  
    <!-- 2.jquery库jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <!--3.bootstrap主要的库 Include all compiled plugins (below), or include individual files as needed -->
    <script src="../dist/js/bootstrap.min.js"></script>
  <script type="text/javascript">
    </script>
  </body>
</html>